package cn.jbit.stream.clone;

import cn.jbit.stream.pojo.User;
import org.junit.jupiter.api.Test;

import java.util.Date;

/**
 * 测试深拷贝与浅拷贝
 * java自带的拷贝是浅拷贝
 *
 * json的序列化与反序列化采用的是深拷贝
 *
 */
public class TestDeepAndqianCopy {

    @Test
    public  void  testDeep() throws CloneNotSupportedException {

        User user=new User();
        user.setId(1);
        user.setName("zaicheng");
        user.setPassword("123.com");
        user.setDate(new Date());


        User user1= (User) user.clone();

        user1.setName("sss");

        System.out.println(user1);

        System.out.println(user==user1);


    }



}
